package com.example.hdwx.myapplication.untils;

import android.util.Log;

import com.example.hdwx.myapplication.eneity.Api;
import com.example.hdwx.myapplication.eneity.Cooklist_enetity;
import com.example.hdwx.myapplication.json.Cooklist_Json;
import com.example.hdwx.myapplication.eneity.Cooklist_enetity;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by hudongwx on 17-2-18.
 */

public class HttpUntils {
    public static List<Cooklist_enetity> list=new ArrayList();
    public static List<Cooklist_enetity> gethttp(){
        for (int i = 0 ; i < 11; i++) {
        OkHttpUtils.get()
                    .url(new Api().PATH(i))
                    .build()
                    .execute(new StringCallback() {
                        @Override
                        //下载失败调用的方法
                        public void onError(Request request, Exception e) {
                            Log.e("erro","下载失败");
                        }
                        //下载成功调用的方法
                        @Override
                        public void onResponse(String response) {
                            //解析json数据，得到一个List<Daydaycook_cooklist>的集合；
                            list = Cooklist_Json.cooklist_json(response);
                        }
                    });
            Log.e("4444","6555555"+new Api().PATH(i));
        }
        return list;
   }
}
